package com.heima.model.article.dots;

import lombok.Data;

@Data
public class UpdateArticleMsg {
    private Long articleId;
    private Integer likes;
    private Integer collection;
    private Integer comment;
    private Integer views;
    public static UpdateArticleMsg getInit()
    {
        UpdateArticleMsg updateArticleMsg = new UpdateArticleMsg();
        updateArticleMsg.setLikes(0);
        updateArticleMsg.setViews(0);
        updateArticleMsg.setCollection(0);
        updateArticleMsg.setComment(0);
        return updateArticleMsg;
    }
    public static UpdateArticleMsg getInit(UpdateArticleMsg obj)
    {
        if(obj==null)
            return getInit();
        if(obj.likes==null)
            obj.likes=0;
        if(obj.collection==null)
            obj.collection=0;
        if(obj.comment==null)
            obj.comment=0;
        if(obj.views==null)
            obj.views=0;
        return obj;
    }
    public UpdateArticleMsg add(UpdateArticleMsg old)
    {
        getInit(old);
        getInit(this);
        this.likes+=old.getLikes();
        this.views+=old.getViews();
        this.comment+=old.getComment();
        this.collection+=old.getCollection();
        return this;
    }
}
